Added a section about usage when you want to manage the expanded widgets
authorFederico Mena Quintero <federico@ximian.com>
Tue, 24 Feb 2004 23:09:16 +0000 (23:09 +0000)
committerFederico Mena Quintero <federico@src.gnome.org>
Tue, 24 Feb 2004 23:09:16 +0000 (23:09 +0000)
2004-02-24  Federico Mena Quintero  <federico@ximian.com>

* gtk/tmpl/gtkexpander.sgml: Added a section about usage when you
want to manage the expanded widgets yourself.

docs/reference/ChangeLog
docs/reference/gtk/tmpl/gtkexpander.sgml

index c65dc75eafc609901daf947028a3a372ce66e5e4..978af660b196c9d30c884b99d8798dafddc0c5b8 100644 (file)
@@ -1,3 +1,8 @@
+2004-02-24  Federico Mena Quintero  <federico@ximian.com>
+
+       * gtk/tmpl/gtkexpander.sgml: Added a section about usage when you
+       want to manage the expanded widgets yourself.
+
 Tue Feb 24 14:45:03 2004  Owen Taylor  <otaylor@redhat.com>
 
        * === Released 2.3.3 ===
index d75a576881a80991948475356e7c97204918ef9d..b306f30083f73bff79560daeb62fed67b58630bd 100644 (file)
@@ -10,6 +10,56 @@ A #GtkExpander allows the user to hide or show its child by clicking on an expan
 the triangles used in a #GtkTreeView.
 </para>
 
+  <para>
+    Normally you use an expander as you would use any other descendant
+    of #GtkBin; you create the child widget and use
+    gtk_container_add() to add it to the expander.  When the expander
+    is toggled, it will take care of showing and hiding the child
+    automatically.
+  </para>
+
+  <section id="expander-special-usage">
+    <title>Special Usage</title>
+
+    <para>
+      There there are situations in which you may prefer to show and
+      hide the expanded widget yourself, such as when you want to
+      actually create the widget at expansion time.  In this case,
+      create a #GtkExpander but do not add a child to it.  The
+      expander widget has an <literal>expanded</literal> property
+      which can be used to monitor its expansion state.  You should
+      watch this property with a signal connection as follows:
+    </para>
+
+    <programlisting id="expander-callback-example">
+expander = gtk_expander_new_with_mnemonic ("_More Options");
+g_signal_connect (expander, "notify::expanded",
+                  G_CALLBACK (expander_callback), NULL);
+
+...
+
+static void
+expander_callback (GObject    *object,
+                   GParamSpec *param_spec,
+                   gpointer    user_data)
+{
+  GtkExpander *expander;
+
+  expander = GTK_EXPANDER (object);
+
+  if (gtk_expander_get_expanded (expander))
+    {
+      /* Show or create widgets */
+    }
+  else
+    {
+      /* Hide or destroy widgets */
+    }
+}
+
+    </programlisting>
+  </section>
+
 <!-- ##### SECTION See_Also ##### -->
 <para>